<template>
	<view class="entire">
		<view style="width: 100%;height: 30rpx;"></view>
		<view class="square test" style="position: relative;">
			<view class="flex p-xs margin-bottom-sm mb-sm">
				<view class="flex-quadruple padding-sm margin-xs radius" style="padding-right: 0 !important;">
					<view class='headimg'>
						<image style="width: 100rpx;height: 100rpx;border-radius: 100rpx;" :src="postinfo.user.avatar">
						</image>
					</view>
				</view>
				<view class="flex-sub padding-sm margin-xs radius"
					style="width: 56% !important;padding-left: 0 !important;">
					<view style="font-size: 45rpx;color: white;">{{postinfo.user.nickname}}</view>
					<view style="font-size: 35rpx;color: #b1c2d7;">{{postinfo.create_time}}</view>
				</view>
				<!-- <view style="display: flex;padding: 25rpx 20rpx 0 0;" v-if="item.is_author == 1">
					<view style="font-size: 30rpx;color:#fff;padding-right: 20rpx;" @click="deletePost(item)">删除
					</view>
					<view style="font-size: 30rpx;color:#fff;" @click="updatePost(item)">修改</view>
				</view> -->
			</view>
			<view class="flex p-xs margin-bottom-sm mb-sm" style="margin-top: -50rpx;">
				<view v-if="token" class="flex-sub padding-sm margin-xs radius rich-text-container text_height" style="width: 98%;">
					<rich-text class="rich-text"
						style="width: 98%;font-size: 30rpx;color: white;overflow: hidden;word-wrap: break-word;word-break: break-all;"
						:nodes="postinfo.content.replace(/\n/g, '<br>')"></rich-text>
				</view>
				<view v-else class="flex-sub padding-sm margin-xs radius rich-text-container text_height" style="font-size: 30rpx;color: white;max-width: 90%; white-space: nowrap;overflow: hidden; text-overflow: ellipsis;">
					<!-- <rich-text class="rich-text"
						style="width: 98%;overflow: hidden;word-wrap: break-word;word-break: break-all;text-overflow: ellipsis;"
						:nodes="postinfo.content.replace(/\n/g, '<br>')"></rich-text> -->
						{{postinfo.content}}
				</view>
			</view>
			<view>
				<view v-for="(img,img_index) in postinfo.file_img" :key="img_index"
					v-if="postinfo.file_img && postinfo.file_img.length > 0"
					style="display: inline-block;width: 30%;height: 180rpx;padding: 0 10rpx;">
					<image style="width: 100%;height: 100%;margin-left: 30rpx;" @click="tankuang(img,postinfo.file_img)"
						:src="img" mode="aspectFill"></image>
				</view>
			</view>
			<view style="display: flex; justify-content: center; align-items: center;"
				v-for="(video,index) in postinfo.file_video">
				<video :src="video"></video>
			</view>
			<view v-for="(datafile,ind) in postinfo.file_data">
				<view
					style="color:#26c3dd; padding:10rpx 0 10rpx 20rpx;font-size: 30rpx;overflow: hidden;word-wrap: break-word;word-break: break-all;"
					@click="downloadFiles(ind,datafile)">
					{{datafile.filename}}
				</view>
			</view>

			<view v-if="token">
				<view class="introduce" v-for="(item1,index1) in commentinfo" :key="index1">
					<view class="introduce_comment">
						<view>
							<view style="width: 100%;height:30rpx;"></view>
							<view
								style="font-size: 35rpx;color: #1EEBE6;display: flex;justify-content: space-between;align-items: center;">
								<view style="display: flex;justify-content: space-between;align-items: center;">
									<view class="cu-avatar round margin-left"
										:style="{'background-image':'url('+ item1.user.avatar +')'}"></view>
									<view style="font-size: 35rpx;">{{item1.user.nickname}}</view>
								</view>
								<view style="display: flex;justify-content: space-between;align-items: center;">
									<view style="color: #fff;font-size: 30rpx;margin-right: 20rpx;"
										@tap="showModal1(item1.aid,item1.id)" data-target="menuModal1">评论</view>
									<view style="color: #fff;font-size: 30rpx;margin-right: 20rpx;"
										@click.stop="deleteComment(item1.id)" v-if='item1.is_author == 1'>删除</view>
									<view style="color: #fff;font-size: 30rpx;margin-right: 20rpx;"
										@tap="showModal3(item1.aid,item1.id,item1)" data-target="menuModal3"
										v-if='item1.is_author == 1'>修改</view>
								</view>
							</view>
							<view style="margin-left: 20rpx;padding-top: 15rpx;" class="rich-text-container">
								<rich-text class="rich-text" style="color: #fff;font-size: 30rpx;"
									:nodes="item1.content_text"></rich-text>
								<view v-if="item1.content_files != ''">
									<image style="width: 26%;height: 200rpx;margin-left: 30rpx;" :src="img"
										v-for="(img,index) in item1.content_files_img" :key="index"></image>
								</view>
							</view>
							<view style="width: 100%;height:30rpx;"></view>
							<view class="cu-modal" :class="modalName1=='menuModal1'?'show':''" @tap="hideModal1"
								style="z-index: 999;">
								<view class="cu-dialog" @tap.stop>
									<view style="padding: 20rpx 0 30rpx 30rpx;font-size: 40rpx;font-weight: 600;">发表评论
									</view>
									<view class="flex p-xs margin-bottom-sm mb-sm" style="">
										<!-- <view class="flex-quadruple padding-sm margin-xs radius" style="padding-right: 0;">
											<view class='headimg1'>
												<image style="width: 100%;height: 100%;border-radius: 100rpx;"
													:src="userinfo.avatar"></image>
											</view>
										</view> -->
										<view class="flex-sub padding-sm margin-xs radius"
											style="padding-left: 10rpx;position: relative;">
											<!-- 				<textarea class="inputstyle"
												style="padding-top: 10px;padding-right: 55px; width: 500rpx;"
												v-model="text2" placeholder="欢迎评论"></textarea> -->

											<textarea class="inputstyle_sty" :style="{ height: textareaHeight_ss }"
												style="padding-top: 3px;padding-right: 50px;text-align: left;"
												v-model="text2" placeholder="欢迎评论" rows="1"
												@input="updateTextareaHeight($event,3)"></textarea>

											<image
												style="width: 50rpx;height:50rpx;position: absolute;bottom:20rpx;right: 40rpx;z-index:999;"
												@click="ChooseImage(item1.id,2)" src="@/static/upimg.png"></image>
											<image
												style="width: 50rpx;height:50rpx;position: absolute;bottom:20rpx;right: 90rpx;z-index:999;"
												@click="showPopup(0,2)" src="@/static/emoji.png"></image>
										</view>
										<view
											style="padding: 20rpx 20rpx 0 0;font-size: 40rpx;color: #000000;margin-top: 18rpx;"
											@click="comment_first(aid,pinglun_id)">
											发送
										</view>
									</view>
									<view style="width: 100%;height: 200rpx;" v-if="imgLists.length > 0">
										<view style="display: inline-block;position: relative;"
											v-for="(img,index2) in imgLists" :key="index2">
											<image style="width: 160rpx;height: 160rpx;float: left;padding-left: 20rpx;"
												:src="img"></image>
											<image
												style="width: 30rpx;height: 30rpx;position: absolute;top: -15rpx;right: -15rpx;"
												@click="delimg(index2)" src="@/static/close.png"></image>
										</view>
									</view>
								</view>
							</view>
						</view>

						<view class="cu-modal" :class="modalName3=='menuModal3'?'show':''" @tap="hideModal3"
							style="z-index: 999;">
							<view class="cu-dialog" @tap.stop>
								<view style="padding: 20rpx 0 30rpx 30rpx;font-size: 40rpx;font-weight: 600;">
									修改评论</view>
								<view class="flex p-xs margin-bottom-sm mb-sm" style="">
									<!-- <view class="flex-quadruple padding-sm margin-xs radius" style="padding-right: 0;">
										<view class='headimg1'>
											<image style="width: 100%;height: 100%;border-radius: 100rpx;"
												:src="userinfo.avatar">
											</image>
										</view>
									</view> -->

									<view class="flex-sub padding-sm margin-xs radius"
										style="padding-left: 10rpx;position: relative;">



										<!-- 			<textarea class="inputstyle" style="padding: 10px 55px 0 0;width: 500rpx;"
											v-model="text4" placeholder=""></textarea> -->

										<textarea class="inputstyle_sty" :style="{ height: textareaHeight_sss }"
											style="padding-top: 3px;padding-right: 50px;text-align: left;"
											v-model="text4" placeholder="欢迎评论" rows="1"
											@input="updateTextareaHeight($event,4)"></textarea>



										<image
											style="width: 50rpx;height:50rpx;position: absolute;bottom:20rpx;right: 40rpx;z-index:999;"
											@click="update_ChooseImage()" src="@/static/upimg.png"></image>
										<image
											style="width: 50rpx;height:50rpx;position: absolute;bottom:20rpx;right: 90rpx;z-index:999;"
											@click="showPopup(0,4)" src="@/static/emoji.png"></image>
									</view>

									<view
										style="padding: 20rpx 20rpx 0 0;font-size: 40rpx;color: #000000;margin-top: 18rpx;"
										@click="comment_update()">
										发送
									</view>
								</view>
								<view style="width: 100%;height: 200rpx;" v-if="imgListsss.length > 0">
									<view style="display: inline-block;position: relative;"
										v-for="(img,index4) in imgListsss" :key="index4">
										<image style="width: 160rpx;height: 160rpx;float: left;padding-left: 20rpx;"
											:src="img">
										</image>
										<image
											style="width: 30rpx;height: 30rpx;position: absolute;top: -15rpx;right: -15rpx;"
											@click="delimg_update(index4)" src="@/static/close.png"></image>
									</view>
								</view>
							</view>
						</view>

						<view class="introduce_comment" v-for="(item2,index2) in item1.children" :key="index2"
							style="margin-left: 25rpx;width: 95%;">
							<view>
								<view
									style="font-size: 35rpx;color: #1EEBE6;display: flex;justify-content: space-between;align-items: center;">
									<view style="display: flex;justify-content: space-between;align-items: center;">
										<view class="cu-avatar round margin-left"
											:style="{'background-image':'url('+ item2.user.avatar +')'}"></view>
										<view style="font-size: 35rpx;">{{item2.user.nickname}}</view>
									</view>
									<view style="display: flex;justify-content: space-between;align-items: center;">
										<view style="color: #fff;font-size: 30rpx;margin-right: 20rpx;"
											@tap="showModal2(item2.aid,item1.id)" data-target="menuModal1">评论</view>
										<view style="color: #fff;font-size: 30rpx;margin-right: 20rpx;"
											@click.stop="deleteComment(item2.id)">删除</view>
										<view style="color: #fff;font-size: 30rpx;margin-right: 20rpx;"
											@tap="showModal3(item2.aid,item2.id,item2)" data-target="menuModal3">修改
										</view>
									</view>
								</view>
								<view style="margin-left: 20rpx;padding-top: 15rpx;">
									<rich-text style="color: #fff;" :nodes="item2.content_text"></rich-text>
									<view v-if="item2.content_files != ''">
										<image style="width: 26%;height: 200rpx;margin-left: 30rpx;" :src="img"
											v-for="(img,index3) in item2.content_files_img" :key="index3"></image>
									</view>
								</view>
								<view style="width: 100%;height:30rpx;"></view>
								<view class="cu-modal" :class="modalName2=='menuModal2'?'show':''" @tap="hideModal2"
									style="z-index: 999;">
									<view class="cu-dialog" @tap.stop>
										<view style="padding: 20rpx 0 30rpx 30rpx;font-size: 40rpx;font-weight: 600;">
											发表评论</view>
										<view class="flex p-xs margin-bottom-sm mb-sm" style="">
											<view class="flex-sub padding-sm margin-xs radius"
												style="padding-left: 0;position: relative;">


												<textarea class="inputstyle_sty" :style="{ height: textareaHeight_s }"
													style="padding-top: 3px;padding-right: 50px;text-align: left;"
													v-model="text3" placeholder="欢迎评论" rows="1"
													@input="updateTextareaHeight($event,2)"></textarea>

												<image
													style="width: 50rpx;height:50rpx;position: absolute;bottom:20rpx;right: 40rpx;z-index:999;"
													@click="ChooseImage(item2.id,3)" src="@/static/upimg.png"></image>
												<image
													style="width: 50rpx;height:50rpx;position: absolute;bottom:20rpx;right: 90rpx;z-index:999;"
													@click="showPopup(0,3)" src="@/static/emoji.png"></image>
											</view>

											<view
												style="padding: 20rpx 20rpx 0 0;font-size: 40rpx;color: #000000;margin-top: 18rpx;"
												@click="comment_second(aid,pinglun_id)">
												发送
											</view>
										</view>
										<view style="width: 100%;height: 200rpx;" v-if="imgListss.length > 0">
											<view style="display: inline-block;position: relative;"
												v-for="(img,index4) in imgListss" :key="index4">
												<image
													style="width: 160rpx;height: 160rpx;float: left;padding-left: 20rpx;"
													:src="img"></image>
												<image
													style="width: 30rpx;height: 30rpx;position: absolute;top: -15rpx;right: -15rpx;"
													@click="delimg(index4)" src="@/static/close.png"></image>
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>


				<view style="font-size: 25rpx;color:#fff;padding: 0 0 50rpx 20rpx;" @click="see_more(postinfo.id)"
					v-if="postinfo.comment_count > 10">查看更多评论
				</view>

				<view class="flex p-xs margin-bottom-sm mb-sm" style="margin-top: -10rpx;">
					<view style="display: flex;align-items: center;width: 100%;">
						<!-- <view class="flex-quadruple padding-sm margin-xs radius" style="padding-top: 30rpx;">
							<view class='headimg1'>
								<image style="width: 100%;height: 100%;border-radius: 100rpx;" :src="userinfo.avatar">
								</image>
							</view>
						</view> -->
						<view class="flex-sub padding-sm margin-xs radius" style="padding-left: 10rpx;position: relative;height: 100%;">
							<textarea class="inputstyle_sty" :style="{ height: textareaHeight }"
								style="padding-right: 55px;text-align: left;padding-top: 4rpx;" v-model="commentText[postinfo.id]"
								placeholder="欢迎评论" rows="1" @input="updateTextareaHeight($event,1)"></textarea>

							<image
								style="width: 50rpx;height:50rpx;position: absolute;bottom:40rpx;right: 40rpx;z-index:999;"
								@click="ChooseImage(postinfo.id,1)" src="@/static/upimg.png"></image>
							<image
								style="width: 50rpx;height:50rpx;position: absolute;bottom:40rpx;right: 90rpx;z-index:999;"
								@click="showPopup(postinfo.id,1)" src="@/static/emoji.png"></image>
						</view>

						<view style="font-size: 30rpx;color: #fff;padding: 10rpx 20rpx 0 0;"
							@click="submit(postinfo.id,postinfo.channel_pid,postinfo.channel_id)">
							发送
						</view>
					</view>
				</view>
				<view style="width: 100%;height: 200rpx;" v-if="imgList.length > 0 && img_id == postinfo.id">
					<view style="display: inline-block;position: relative;" v-for="(img,index2) in imgList"
						:key="index2">
						<image style="width: 160rpx;height: 160rpx;float: left;padding-left: 20rpx;" :src="img"></image>
						<image style="width: 30rpx;height: 30rpx;position: absolute;top: -15rpx;right: -15rpx;"
							@click="delimg(index2)" src="@/static/close.png"></image>
					</view>
				</view>
				<view style="width:95%;margin:auto;height:5rpx;background-color:#6386b5;margin-top:-20rpx;"></view>
				<view class="flex p-xs margin-bottom-sm mb-sm" style="height: 70rpx;">

					<!-- 					<view class="flex-sub padding-sm margin-xs radius">
						<view class='cuIcon-favorfill text-white' style="color: #F4C044;" @click="uncollect(item.id)"
							v-if="item.is_myfavorite == 1">{{item.post_favorites}}</view>
						<view class='cuIcon-favor text-white' @click="collect(item.id)" v-else>{{item.post_favorites}}
						</view>
					</view> -->

					<view class="flex-sub padding-sm margin-xs radius"
						style="height: 50rpx;display: flex;align-items: center;">
						<button open-type="share" class="share_btn" @click.stop="share(postinfo)"
							style="border:1px sopadding: 0rpx;background-color: #0d4283;height: 40rpx; display: flex; align-items: center;justify-content: center;">
							<view class='cuIcon-post text-white' style="width: 5px;"></view>
						</button>
					</view>

					<view class="flex-sub padding-sm margin-xs radius"
						style="display: flex;align-items: center;justify-content: center;">
						<view class='cuIcon-comment text-white'>{{postinfo.comment_count}}</view>
					</view>

					<view class="flex-sub padding-sm margin-xs radius"
						style="display: flex;align-items: center;justify-content: center;">
						<view class='cuIcon-appreciatefill text-white' style="color: #F4C044;"
							@click="uncollect(postinfo.id)" v-if="postinfo.is_like == 1">{{postinfo.post_favorites}}
						</view>
						<view class='cuIcon-appreciate text-white' @click="collect(postinfo.id)" v-else>
							{{postinfo.post_favorites}}
						</view>
					</view>
				</view>
			</view>
			<view v-else style="padding: 20px;">
				<button style="background: #112858;color:#fff;text-align:center;"  @click="login()">登录后查看</button>
			</view>
			<fui-bottom-popup :show="show4" @close="closePopup()" maskBackground="rgba(0,0,0,0.1)">
				<view class="fui-custom__wrap">
					<chat-icon @changeText="getIcon($event)"></chat-icon>
				</view>
			</fui-bottom-popup>
		</view>
	</view>
</template>

<script>
	import chatIcon from '@/components/chatIcon.vue'
	import user from '@/api/user.js';
	import forum from '@/api/forum.js';
	import {
		img_upload
	} from '@/common/config'
	export default {
		components: {
			chatIcon
		},
		data() {
			return {
				userinfo: [],
				id: '',
				fid: '',
				postinfo: [],
				commentinfo: [],
				forum_comment: [],
				forum_id: [],
				comment_page: 3,
				commentText: {},
				token: '',
				showLogin: true,
				TabCur: 0,
				scrollLeft: 0,
				title: '债市论坛',
				localArray: [],
				allArray: [],
				updateList: [],
				type: 1,
				scrollHeight: 0,
				lowerThreshold: 10,
				isReachedBottom: false,
				page: 2,
				limits: 1,
				pagetype: 1,
				modalName: null,
				modalName1: null,
				modalName2: null,
				modalName3: null,
				swiperList: [],
				herald: [],
				fid: 0,
				fid_type: 'plate',
				show4: false,
				dotStyle: false,
				text2: '',
				text3: '',
				text4: '',
				aid: 0,
				pinglun_id: 0,
				//一级评论
				imgList: [],
				imgdata: [],
				file_img: [],
				file_imgs: [],
				img_id: '',
				//二级评论
				imgLists: [],
				imgdatas: [],
				file_imgs: [],
				file_imgss: [],
				img_ids: '',
				//三级评论
				imgListss: [],
				imgdatass: [],
				file_imgss: [],
				file_imgsss: [],
				img_idss: '',
				//修改评论
				imgListsss: [],
				imgdatasss: [],
				file_imgsss: [],
				file_imgssss: [],
				img_idsss: '',
				//上传图片类型 1一级2二级3三级
				img_type: 1,
				emoji_text: '',
				emoji_type: '',
				textareaHeight: '60rpx',
				textareaHeight_s: '',
				textareaHeight_ss: '',
				textareaHeight_sss: '',
				isLogin: false,
			}
		},
		onLoad(options) {
			const token = uni.getStorageSync('token');
			this.token = token
			this.id = options.id;
			this.fid = options.fid;
			this.init()
			if (this.token) {
				this.isLogin = true
			} else {
				this.isLogin = false
				return
			}
			// this.text()
			user.getUserDetails({
				token: this.token
			}).then(res => {
				this.userinfo = res.data
			});
		},
		onShareAppMessage() {
			const url = uni.getStorageSync('url')
			// const text = uni.getStorageSync('text')
			const url_text = uni.getStorageSync('url_text')
			const url_iamge = uni.getStorageSync('url_iamge')
			return {
				title: url_text,
				path: url,
				imageUrl: url_iamge
			}
		},
		methods: {
			login(){
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
			updateTextareaHeight(event, id) {
				const value = event.target.value;
				if (value !== undefined) {
					const lines = value.split('\n').length;
					const liness = Math.ceil(value.length / 2);
					const num = lines + liness
					if (id === 1) {
						this.textareaHeight = `${num * 20}px`;
					} else if (id === 2) {
						this.textareaHeight_s = `${num * 20}px`;
					} else if (id === 3) {
						this.textareaHeight_ss = `${num * 20}px`;
					} else {
						this.textareaHeight_sss = `${num * 20}px`;
					}
				}
			},
			getIcon(e) {
				console.log(e)
				if (this.emoji_type == 1) {
					if (this.commentText[this.emoji_text] == undefined) {
						this.commentText[this.emoji_text] = e
					} else {
						this.commentText[this.emoji_text] += e
					}
				} else if (this.emoji_type == 3) {
					if (this.text3 == undefined) {
						this.text3 = e
					} else {
						this.text3 += e
					}
				} else if (this.emoji_type == 4) {
					if (this.text4 == undefined) {
						this.text4 = e
					} else {
						this.text4 += e
					}
				} else if (this.emoji_type == 2) {
					if (this.text2 == undefined) {
						this.text2 = e
					} else {
						this.text2 += e
					}
				}

				this.closePopup()
			},
			showPopup(item, type) {
				this.emoji_type = type
				this.emoji_text = item
				this.show4 = true
			},
			closePopup() {
				this.show4 = false
			},
			init() {
				forum.postShow({
					id: this.id,
					category_type: 'plate',
				}).then(res => {
					this.postinfo = res.data.plateInfo
					let data = res.data.commentList
					for (var i = 0; i < data.length; i++) {
						if (data[i]['content_files'] != '' || data[i]['content_files'] !=
							null) {
							console.log(data[i]['content_files'], 666)
							const imageUrlArray = data[i]['content_files'].split(',');
							data[i]['content_files_img'] = imageUrlArray
						} else {
							data[i]['content_files_img'] = []
						}
						if (data[i]['children'] != []) {
							for (var j = 0; j < data[i]['children'].length; j++) {
								if (data[i]['children']['content_files'] != '' || data[i][
										'content_files'
									] !=
									null) {
									const imageUrlArrays = data[i]['children'][j][
											'content_files'
										]
										.split(',');
									data[i]['children'][j]['content_files_img'] =
										imageUrlArrays
								} else {
									data[i]['children'][j]['content_files_img'] = []
								}
							}
						}
					}
					this.commentinfo = data
				})
			},
			//图片预览
			tankuang(url, arr) {
				uni.previewImage({
					current: url,
					urls: arr,
					loop: true,
				});
			},
			downloadFiles(index, datafile) {
				const url = datafile.url; // 替换为实际文件的URL
				const fileName = datafile.filename; // 替换为实际文件的名称
				const res = uni.downloadFile({
					url: url,
					success: (downloadResult) => { // 使用箭头函数
						if (downloadResult.statusCode === 200) {
							const tempFilePath = downloadResult.tempFilePath
							console.log(tempFilePath, 888)
							uni.showToast({
								title: '下载成功',
								icon: 'success'
							})
							this.openTempFile(tempFilePath) // 此处的this仍然指向downloadFiles函数
						} else {
							console.error('文件下载失败')
						}
					},
					fail: (error) => { // 使用箭头函数
						console.error('文件下载失败', error)
					}
				})
				res.onProgressUpdate((progress) => {
					console.log('下载进度：' + progress.progress)
				})
			},
			openTempFile(url) {
				wx.openDocument({
					filePath: url,
					success: (res) => { // 使用箭头函数
						console.log('临时文件打开成功')
					},
					fail: (error) => { // 使用箭头函数
						console.error('打开临时文件失败', error)
					}
				})
			},
			deletePost(item) {
				forum.delPost({
					category_type: item.category_type,
					id: item.id
				}).then(res => {
					if (res.code === 1) {
						uni.showToast({
							title: '删除成功',
							icon: 'success'
						})
						this.infoList(this.fid)
					}
				})
			},
			updatePost(item) {
				uni.navigateTo({
					url: 'updatePost',
				});
				uni.setStorageSync('arrayList', item);
			},
			infoList(id) {
				forum.forumindex({
					token: this.token,
					category_id: id,
					category_type: 'plate',
					type: this.dateTypes,
					Page: 1,
					limit: 5,
					start_time: this.start_time,
					end_time: this.end_time,
				}).then(res => {
					if (res.msg == "尚未开通会员") {
						this.localArray = []
						this.allArray = []
						this.type = 2
						uni.showModal({
							title: '会员',
							content: '开通会员',
							cancelText: '取消',
							confirmText: '确定',
							success: res => {
								if (res.confirm) {
									uni.navigateTo({
										url: '/pages/membership/membership'
									})
								}
							}
						})
					} else {
						this.allArray = res.data
						this.type = 2
					}
				})
			},
			deleteComment(id) {
				forum.delComment({
					id: id
				}).then(res => {
					if (res.code == 1) {
						uni.showToast({
							title: '删除成功',
							icon: 'success'
						})
						this.init()
					}
				})
			},
			collect(id) {
				forum.addFavorite({
					token: this.token,
					table_name: 'plate_post',
					object_id: id,
				}).then(res => {
					this.init()
				})
			},
			uncollect(id) {
				forum.delFavorite({
					token: this.token,
					table_name: 'plate_post',
					object_id: id,
				}).then(res => {
					this.init()
				})
			},
			removeHtmlTags(str) {
				return str.replace(/<[^>]+>/g, '');
			},
			share(item) {
				const url = '/pages/bondmarket/postinfo?id=' + item.id + '&fid=' + this.fid
				if (item.content !== '') {
					uni.setStorageSync('url_text', this.removeHtmlTags(item.content));
				} else {
					uni.setStorageSync('url_text', '');
				}
				if (item.file_img.length !== 0) {
					uni.setStorageSync('url_iamge', item.file_img[0]);
				} else {
					uni.setStorageSync('url_iamge', '');
				}
				uni.setStorageSync('url', url);
			},
			// //发送一级评论 
			// submit(wid, pid, id) {
			// 	let text = this.commentText[wid] || '';
			// 	let texts = this.commentText[wid] || '';
			// 	if (this.file_img && this.file_img.length > 0) {
			// 		for (let i = 0; i < this.file_img.length; i++) {
			// 			text += `![Image Description](${this.file_img[i]})`
			// 		}
			// 	}
			// 	forum.addComment({
			// 		token: this.token,
			// 		type: 'bbs',
			// 		aid: wid,
			// 		content: text,
			// 		con: texts,
			// 		image: this.imgList, 
			// 		pid: 0,
			// 		top_pid: 0,
			// 	}).then(res => {
			// 		if (res.code == 1) {
			// 			this.init()
			// 			console.log(123)
			// 			// uni.showToast({
			// 			// 	title: '发布成功',
			// 			// 	icon: 'success'
			// 			// })	
			// 		}
			// 	})
			// },
			showModal(e) {
				this.modalName = e.currentTarget.dataset.target
				forum.get_management({
					token: this.token,
				}).then(res => {
					if (res.code == 1) {
						this.swiperList = res.data
					}
				})
				forum.getLiveForeshow().then(res => {
					if (res.code == 1) {
						this.herald = res.data
					}
				})
			},
			showModal1(aid, id) {
				this.modalName1 = 'menuModal1'
				this.aid = aid
				this.pinglun_id = id
			},
			showModal2(aid, id) {
				this.modalName2 = 'menuModal2'
				this.aid = aid
				this.pinglun_id = id
			},
			showModal3(aid, id, item) {
				if (item.content_files != '') {
					this.imgListsss = item.content_files_img
				} else {
					this.imgListsss = []
				}
				this.modalName3 = 'menuModal3'
				this.aid = aid
				this.pinglun_id = id
				this.updateList = item
				if (!item.content_text) {
					this.text4 = ' '
				} else {
					this.text4 = item.content_text
				}
			},
			hideModal(e) {
				this.modalName = null
			},
			hideModal1(e) {
				this.modalName1 = null
			},
			hideModal2(e) {
				this.modalName2 = null
			},
			hideModal3(e) {
				this.modalName3 = null
			},
			DotStyle(e) {
				this.dotStyle = e.detail.value
			},
			cardSwiper(e) {
				this.cardCur = e.detail.current
			},
			TowerSwiper(name) {
				let list = this[name];
				for (let i = 0; i < list.length; i++) {
					list[i].zIndex = parseInt(list.length / 2) + 1 - Math.abs(i - parseInt(list
						.length / 2))
					list[i].mLeft = i - parseInt(list.length / 2)
				}
				this.swiperList = list
			},

			// towerSwiper触摸开始
			TowerStart(e) {
				this.towerStart = e.touches[0].pageX
			},

			// towerSwiper计算方向
			TowerMove(e) {
				this.direction = e.touches[0].pageX - this.towerStart > 0 ? 'right' : 'left'
			},

			// towerSwiper计算滚动
			TowerEnd(e) {
				let direction = this.direction;
				let list = this.swiperList;
				if (direction == 'right') {
					let mLeft = list[0].mLeft;
					let zIndex = list[0].zIndex;
					for (let i = 1; i < this.swiperList.length; i++) {
						this.swiperList[i - 1].mLeft = this.swiperList[i].mLeft
						this.swiperList[i - 1].zIndex = this.swiperList[i].zIndex
					}
					this.swiperList[list.length - 1].mLeft = mLeft;
					this.swiperList[list.length - 1].zIndex = zIndex;
				} else {
					let mLeft = list[list.length - 1].mLeft;
					let zIndex = list[list.length - 1].zIndex;
					for (let i = this.swiperList.length - 1; i > 0; i--) {
						this.swiperList[i].mLeft = this.swiperList[i - 1].mLeft
						this.swiperList[i].zIndex = this.swiperList[i - 1].zIndex
					}
					this.swiperList[0].mLeft = mLeft;
					this.swiperList[0].zIndex = zIndex;
				}
				this.direction = ""
				this.swiperList = this.swiperList
			},
			//跳转
			broadcast(type, id) {
				uni.setStorageSync('livetype', type);
				uni.setStorageSync('liveid', id);
				uni.navigateTo({
					url: '/pages/index/livbroadcast'
				});
			},
			//查看评论
			see_more(id) {
				forum.AlbumComment({
					token: this.token,
					aid: id,
					type: 'bbs',
					// orderway: 'asc',
					page: this.comment_page,
					limit: 5,
				}).then(res => {
					console.log(this.commentinfo.length, '豆腐干豆腐干的', res.data.total)
					if (res.data.total <= this.commentinfo.length) {
						uni.showToast({
							title: '没有更多了',
							icon: 'none'
						})
						return
					}
					if (this.commentinfo.length == 0) {
						for (var i = 0; i < res.data['list'].length; i++) {
							if (res.data['list'][i]['content_files'] != '') {
								const imageUrlArray = res.data['list'][i]['content_files']
									.split(',');
								res.data['list'][i]['content_files_img'] = imageUrlArray
							} else {
								res.data['list'][i]['content_files_img'] = []
							}
							if (res.data['list'][i]['children'] != []) {
								for (var j = 0; j < res.data['list'][i]['children']
									.length; j++) {
									if (res.data['list'][i]['children']['content_files'] !=
										'') {
										const imageUrlArrays = res.data['list'][i]['children'][
												j
											]['content_files']
											.split(',');
										res.data['list'][i]['children'][j][
											'content_files_img'
										] = imageUrlArrays
									} else {
										res.data['list'][i]['children'][j][
											'content_files_img'
										] = []
									}
								}
							}
						}
						this.commentinfo = res.data
					} else {
						console.log(222)
						for (let i = 0; i < res.data['list'].length; i++) {
							if (res.data['list'][i]['content_files'] != '') {
								const imageUrlArray = res.data['list'][i]['content_files']
									.split(',');
								res.data['list'][i]['content_files_img'] = imageUrlArray
							} else {
								res.data['list'][i]['content_files_img'] = []
							}
							if (res.data['list'][i]['children'] != []) {
								for (var j = 0; j < res.data['list'][i]['children']
									.length; j++) {
									if (res.data['list'][i]['children']['content_files'] !=
										'') {
										const imageUrlArrayss = res.data['list'][i]['children']
											[j]['content_files']
											.split(',');
										res.data['list'][i]['children'][j][
											'content_files_img'
										] = imageUrlArrayss
									} else {
										res.data['list'][i]['children'][j][
											'content_files_img'
										] = []
									}
								}
							}
							this.commentinfo.push(res.data['list'][i])
						}
					}
					console.log(this.commentinfo, 999)


					this.forum_id = id
					if (res.data.total == 0) {
						this.commentinfo = []
						uni.showToast({
							title: '暂无评论',
							icon: 'none'
						})
					}
				});
				this.comment_page += 1
			},
			//发送二级评论
			comment_first(aid, id) {
				let text = this.text2;
				let texts = this.text2;
				if (this.file_imgs && this.file_imgs.length > 0) {
					for (let i = 0; i < this.file_imgs.length; i++) {
						text += `![Image Description](${this.file_imgs[i]})`
					}
				}
				forum.addComment({
					token: this.token,
					type: 'bbs',
					aid: aid,
					content: text,
					con: texts,
					image: this.imgLists,
					pid: id,
					top_pid: aid,
				}).then(res => {
					if (res.code == 1) {
						uni.showToast({
							title: '发布成功',
							icon: 'success'
						})
						this.init()
					}
				})
				this.text2 = ''
				this.modalName1 = null
			},
			//发送三级评论
			comment_second(aid, id) {
				let text = this.text3;
				let texts = this.text3;
				if (this.file_imgss && this.file_imgss.length > 0) {
					for (let i = 0; i < this.file_imgss.length; i++) {
						text += `![Image Description](${this.file_imgss[i]})`
					}
				}
				forum.addComment({
					token: this.token,
					type: 'bbs',
					aid: aid,
					content: text,
					con: texts,
					image: this.imgListss,
					pid: id,
					top_pid: aid,
				}).then(res => {
					if (res.code == 1) {
						uni.showToast({
							title: '发布成功',
							icon: 'success'
						})
						this.modalName2 = null
						this.init()
					}
				})
			},
			//修改评论
			comment_update() {
				let text = this.text4;
				let texts = this.text4;
				if (this.imgListsss && this.imgListsss.length > 0) {
					for (let i = 0; i < this.imgListsss.length; i++) {
						text += `![Image Description](${this.imgListsss[i]})`
					}
				}
				forum.updateComment({
					token: this.token,
					id: this.updateList.id,
					content: text,
					con: texts,
					image: this.imgListsss
				}).then(res => {
					if (res.code == 1) {
						uni.showToast({
							title: '修改成功',
							icon: 'success'
						})
						this.modalName3 = null
						this.init()
					}
				})
			},
			//图片上传弹框
			ChooseImage(id, type) {
				uni.chooseImage({
					count: 3, //默认9 
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						for (let i = 0; i < res.tempFilePaths.length; i++) {
							this.uploadFile(res.tempFilePaths[i], id, type);
						}
					}
				});
			},
			//图片上传
			uploadFile(filePath, id, type) {
				uni.uploadFile({
					url: img_upload,
					filePath: filePath,
					name: 'file',
					formData: {
						'user': 'test',
						'token': this.token
					},
					success: (uploadRes) => {
						const responseObject = JSON.parse(uploadRes.data);
						if (responseObject.code == 403) {
							uni.showToast({
								title: responseObject.msg,
								icon: 'error'
							})
						} else {
							this.img_type = type
							if (type == 1) {
								if (this.imgList.length < 3) {
									console.log(responseObject)
									this.imgdata.push(responseObject.data.fullurl)
									this.imgList = this.imgdata
									this.file_imgs.push(responseObject.data.url)
									this.file_img = this.file_imgs
									this.img_id = id
								} else {
									uni.showToast({
										title: '最多上传三张照片',
										icon: 'none'
									})
								}
							} else if (type == 2) {
								if (this.imgLists.length < 3) {
									console.log(responseObject)
									this.imgdatas.push(responseObject.data.fullurl)
									this.imgLists = this.imgdatas
									this.file_imgss.push(responseObject.data.url)
									this.file_imgs = this.file_imgss
									this.img_ids = id
								} else {
									uni.showToast({
										title: '最多上传三张照片',
										icon: 'none'
									})
								}
							} else {
								if (this.imgListss.length < 3) {
									console.log(responseObject)
									this.imgdatass.push(responseObject.data.fullurl)
									this.imgListss = this.imgdatass
									this.file_imgsss.push(responseObject.data.url)
									this.file_imgss = this.file_imgss
									this.img_idss = id
								} else {
									uni.showToast({
										title: '最多上传三张照片',
										icon: 'none'
									})
								}
							}

						}
					},
					fail: (error) => {
						console.log(error);
					}
				});
			},
			//删除评论时上传的图片
			delimg(e) {
				if (this.img_type == 1) {
					this.file_img.splice(e, 1);
					this.imgList.splice(e, 1);
				} else if (this.img_type == 2) {
					this.file_imgs.splice(e, 1);
					this.imgLists.splice(e, 1);
				} else {
					this.file_imgss.splice(e, 1);
					this.imgListss.splice(e, 1);
				}
			},
			//发送一级评论
			submit(wid, pid, id) {
				let text = this.commentText[wid] || '';
				let texts = this.commentText[wid] || '';
				if (this.file_img && this.file_img.length > 0) {
					for (let i = 0; i < this.file_img.length; i++) {
						text += `![Image Description](${this.file_img[i]})`
					}
				}
				forum.addComment({
					token: this.token,
					type: 'bbs',
					aid: wid,
					content: text,
					con: texts,
					image: this.imgList,
					pid: 0,
					top_pid: 0,
				}).then(res => {
					if (res.code == 1) {
						uni.showToast({
							title: '发布成功',
							icon: 'success'
						})
						this.imgList = []
						this.commentText[wid] = ''
						this.init()
						console.log(123)
					}
				})
			},
			//修改评论图传上传弹窗
			update_ChooseImage() {
				uni.chooseImage({
					count: 3, //默认9 
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						for (let i = 0; i < res.tempFilePaths.length; i++) {
							this.uploadFile1(res.tempFilePaths[i]);
						}
					}
				});
			},
			//修改评论图片上传
			uploadFile1(filePath) {
				uni.uploadFile({
					url: img_upload,
					filePath: filePath,
					name: 'file',
					formData: {
						'user': 'test',
						'token': this.token
					},
					success: (uploadRes) => {
						const responseObject = JSON.parse(uploadRes.data);
						if (responseObject.code == 403) {
							uni.showToast({
								title: responseObject.msg,
								icon: 'error'
							})
						} else {
							if (this.imgList.length < 3) {
								console.log(responseObject)
								this.imgListsss.push(responseObject.data.fullurl)
							} else {
								uni.showToast({
									title: '最多上传三张照片',
									icon: 'none'
								})
							}
						}
					},
					fail: (error) => {
						console.log(error);
					}
				});
			},
			//删除修改时上传的图片
			delimg_update(e) {
				this.imgListsss.splice(e, 1);
			},
		}
	}
</script>

<style>
	.headimg1 {
		width: 60rpx;
		height: 60rpx;
		border: 2rpx white solid;
		border-radius: 100rpx;
		background-size: cover;
		background-repeat: no-repeat;
		background-position: center;
	}

	.entire {
		width: 100%;
		height: 100vh;
		overflow-y: auto;
		background-color: #112858;
	}

	.square {
		width: 90%;
		margin: auto;
		background-color: #0d4283;
		border-radius: 15rpx;
	}

	.inputstyle {
		height: 70rpx;
		border-radius: 100rpx;
		border: 3rpx white solid;
		background-color: white;
		padding-left: 30rpx;
		flex-grow: 1;
		overflow-y: auto;
	}

	.inputstyle_sty {
		/* height: 70rpx; */
		border-radius: 15rpx;
		border: 3rpx white solid;
		background-color: white;
		padding-left: 30rpx;
		width: 97%;
		margin-top: 8px;
		font-size: 30rpx;
		overflow-y: auto;
		min-height: 25px;
		/* resize: none; */
		box-sizing: border-box;
		height: 25px;
		overflow: hidden;
		display: flex;
		align-items: flex-start;
	}

	.introduce_comment {
		width: 98%;
		margin: 10rpx auto 0;
		border-radius: 16rpx;
		background-color: #112858;
	}

	.rich-text-container {
		width: 98%;
		font-size: 36rpx;
		color: white;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.rich-text-container::selection {
		background-color: #007bff;
		/* 设置选中文本的背景色 */
		color: white;
		/* 设置选中文本的文字颜色 */
	}

	.rich-text {
		user-select: text;
		/* 允许文本选择 */
	}

	.fui-custom__wrap {
		width: 100%;
		height: 520rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 9999;
	}

	.share_btn::after {
		border: initial;
	}

	.rich-text-container {
		-webkit-line-clamp: 10;
	}
</style>